import React from 'react';
import { ts2Formatter, renderState, renderEnable } from 'utils';
import moment from 'moment';
import { actions } from 'mirrorx';
{/*
可配置化种类：

1、表格头部字段 
    1、列表页表格头部字段集合 mainTableColumn
    2、编辑页表格头部字段集合 childTableColumn

2、编辑框的字段
    1、编辑页 直接显示在页面的编辑字段 FormField
    2、编辑页 需要点击表格的增行弹框编辑的字段 FormTableField
    3. 列表页查询区域  searchField

3.表头部的按钮  headerButtonSets

4.表行尾部按钮  columnButtonSets
*/}

//表头信息

//字段属性

//基本信息
const FormDataHeader = [{
    enname: "organizationId",
    showname: "organizationName",
    codename: "organizationCode",
    zhname: "隶属组织",
    multiple: false,
    type: "RefComponent",
    cascadeName: [{
        paramkey: "EQ_inventoryOrg.id",
        childtype: "DataHeader",
        refKey: "refpk",
        dtoKey: "organizationId",
        offers: "reportingwarehouseId",
        resetOffersFlag: true,
    },{
        paramkey: "EQ_inventoryOrg.id",
        childtype: "DataHeader",
        refKey: "refpk",
        dtoKey: "organizationId",
        offers: "warehouseId",
        resetOffersFlag: true,
    }, {
        paramkey: "EQ_organization.id",
        childtype: "DataHeader",
        refKey: "refpk",
        dtoKey: "organizationId",
        offers: "regionId",
        resetOffersFlag: true,
    }, {
        paramkey: "EQ_organization.id",
        childtype: "DataHeader",
        refKey: "refpk",
        dtoKey: "organizationId",
        offers: "shippingareaId",
        resetOffersFlag: true,
    }, {
        paramkey: "EQ_organization.id",
        childtype: "DataHeader",
        refKey: "refpk",
        dtoKey: "organizationId",
        offers: "retailId",
        resetOffersFlag: true,
    }
    // ,{
    //     paramkey: "EQ_organization.id",
    //     childtype: "DataHeader",
    //     refKey: "refpk",
    //     dtoKey: "organizationId",
    //     offers: "salesDeptId",  //部门
    //     resetOffersFlag: true,
    // }
    ],
    cascadeChildTable: [{
        refKey: "refpk",
        dtoKey: "organizationId",
        childType: "terminalBases"  //terminalBases terminalSuppliers terminalPersons
    }, {
        refKey: "refpk",
        dtoKey: "organizationId",
        childType: "terminalSuppliers"
    }, {
        refKey: "refpk",
        dtoKey: "organizationId",
        childType: "terminalPersons"
    }, {
        refKey: "refname",
        dtoKey: "organizationName",
        childType: "terminalBases"
    }, {
        refKey: "refname",
        dtoKey: "organizationName",
        childType: "terminalSuppliers"
    }, {
        refKey: "refname",
        dtoKey: "organizationName",
        childType: "terminalPersons"
    }, {
        refKey: "refcode",
        dtoKey: "organizationCode",
        childType: "terminalBases"
    }, {
        refKey: "refcode",
        dtoKey: "organizationCode",
        childType: "terminalSuppliers"
    }, {
        refKey: "refcode",
        dtoKey: "organizationCode",
        childType: "terminalPersons"
    }, {
        refKey: "contictsPersonId",
        dtoKey: "contictsPersonId",
        childType: "terminalBases"
    }, {
        refKey: "contictsPersonName",
        dtoKey: "contictsPersonName",
        childType: "terminalBases"
    }, {
        refKey: "contictsPersonCode",
        dtoKey: "contictsPersonCode",
        childType: "terminalBases"
    }],
    param:{
        "AUTH_refdim":"organization","AUTH_refcod":"TerminalChange"
    },
    requirecontrol: [{
        value: "0001A110000000001TUK,0001X810000000003WAH",
        refKey: "refpk",
        dtoKey: "organizationId",
        layer: ["FormField", "DataHeader", "Field"],
        fields: ["riscode"]
        },
        {
        value: "0001A110000000001TRY",
        refKey: "refpk",
        dtoKey: "organizationId",
        layer: ["FormField", "DataHeaderOther", "Field"],
        fields: ["mailSite"]
        }
    ],
    refname: "organization",
    edit: false,
    required: true,
},
{
    enname: "code",
    zhname: "变更编码",
    type: "FormControl",
    hidepage:{0:true},
    pattern: /^\S*$/,
    message: "不能有空格",
    edit: false,
},
{
    enname: "changeReasonId",
    codename: "changeReasonCode",
    showname: "changeReasonName",
    zhname: "变更原因",
    code: "BGYY",
    type: "Select",
    showcontrol:[
        {
            value: "001",
            refKey: "refcode",
            dtoKey: "changeReasonCode",
            layer: ["childTableColumn", "terminalBases"],
            fields: "all"
        },
        {
            value: "001",
            refKey: "refcode",
            dtoKey: "changeReasonCode",
            layer: ["childTableColumn", "terminalSuppliers"],
            fields: "all"
        },
        {
            value: "001",
            refKey: "refcode",
            dtoKey: "changeReasonCode",
            layer: ["childTableColumn", "terminalPersons"],
            fields: "all"
        },
        {
            value: "002,003",
            refKey: "refcode",
            dtoKey: "changeReasonCode",
            hideFlag:true,
            layer: ["childTableColumn", "terminalBases"],
            fields: "all"
        },
        {
            value: "002,003",
            refKey: "refcode",
            dtoKey: "changeReasonCode",
            hideFlag:true,
            layer: ["childTableColumn", "terminalSuppliers"],
            fields: "all"
        },
        {
            value: "002,003",
            refKey: "refcode",
            dtoKey: "changeReasonCode",
            hideFlag:true,
            layer: ["childTableColumn", "terminalPersons"],
            fields: "all"
        },
    ],
    edit: true,
    required: true,
},
{
    enname: "srcBillCode",
    zhname: "门店编码",
    type: "FormControl",
    pattern: /^\S*$/,
    message: "不能有空格",
    edit: false,
},
{
    enname: "name",
    zhname: "门店名称",
    type: "FormControl",
    componentClass: "textarea",
    edit: false,
    pattern: /^\S*$/,
    message: "不能有空格",
    required: true,
},
{
    enname: "facadeShort",
    zhname: "门店简称",
    type: "FormControl",
    pattern: /^\S*$/,
    message: "不能有空格",
    edit: false,
    required: false,
},
{
    enname: "facadeCategoryId",
    codename: "facadeCategoryCode",
    showname: "facadeCategoryName",
    zhname: "门店类别",
    precision: 2,
    code: "MD002",
    type: "Select",
    edit: false,
    required: true,
},
{
    enname: "peopleAttributeId",
    codename: "peopleAttributeCode",
    showname: "peopleAttributeName",
    zhname: "人员属性",
    refname: "persontypes",
    type: "RefComponent",
    edit: false,
    required: true,
},
{
    enname: "prototypeId",
    codename: "prototypeCode",
    showname: "prototypeName",
    zhname: "样机属性",
    type: "Select",
    code: "YJ001",
    edit: false,
    required: true,
},
{
    enname: "marketLevelId",
    codename: "marketLevelCode",
    showname: "marketLevelName",
    zhname: "市场层面",
    code: "SCM",
    type: "Select",
    edit: false,
    required: true,
},
{
    enname: "warehouseId",
    codename: "warehouseCode",
    showname: "warehouseName",
    zhname: "所属仓库",
    alias: "organizationId",
    hidepage:{0:true,1:true,2:false},
    param:{ EQ_ext07:"Y" },
    refname: "warehouseRefRadio",
    type: "RefComponent",
    edit: false,
    required: false,
},
{
    enname: "canalTypeId",
    codename: "canalTypeCode",
    showname: "canalTypeName",
    zhname: "终端渠道类型",
    refname: "terminalCustRef",
    type: "RefComponent",
    edit: false,
    required: true,
},
{
    enname: "canalCategoryId",
    codename: "canalCategoryCode",
    showname: "canalCategoryName",
    zhname: "门店渠道",
    requirecontrol: [{
        value: "1001A110000000007QTM,1001A110000000007QTX,1001A110000000007QU0,1001A110000000007QOT,1001A110000000007QTP,1001A1100000000G71DI",
        refKey: "refpk",
        dtoKey: "canalCategoryId",
        layer: ["FormField", "DataHeader", "Field"],
        fields: ["storename"]
    }],
    refname: "custchantype",
    type: "RefComponent",
    edit: false,
    required: true,
},
{
    enname: "riscode",
    zhname: "RIS门店编码",
    type: "FormControl",
    pattern: /^\S*$/,
    message: "不能有空格",
    edit: false,
},
{
    enname: "regionId",
    codename: "regionCode",
    showname: "regionName",
    zhname: "区域市场",
    refname: "marketareas",
    type: "RefComponent",
    alias: "organizationId",
    edit: false,
    required: true,
},
{
    enname: "stradeAreaId",
    codename: "stradeAreaCode",
    showname: "stradeAreaName",
    zhname: "所属商圈",
    type: "Select",
    code: "SQ001",
    edit: false,
},
// {
//     enname: "shippingareaId",
//     codename: "shippingareaCode",
//     showname: "shippingareaName",
//     zhname: "发运片区",
//     refname: "departmentRef",
//     type: "RefComponent",
//     alias: "organizationId",
//     edit: false,
//     required: true,
// },
{
    enname: "retailId",
    codename: "retailCode",
    showname: "retailName",
    zhname: "零售片区",
    refname: "departmentRef",
    type: "RefComponent",
    alias: "organizationId",
    param: {
        EQ_enableState: "0",
    },
    edit: false,
    required: true,
},
{
    enname: "reportingwarehouseId",
    codename: "reportingwarehouseCode",
    showname: "reportingwarehouseName",
    zhname: "上报仓库",
    refname: "storeLocation",
    type: "RefComponent",
    param:{
        "AUTH_refdim": "deliveryWarehouse", 
        "AUTH_refcod": "Terminal"
    },
    alias: "organizationId",
    edit: false,
},
{
    enname: "storecode",
    zhname: "客户系统门店编码",
    type: "FormControl",
    pattern: /^\S*$/,
    message: "不能有空格",
    required: false,
    edit: false,
},
{
    enname: "storename",
    zhname: "客户系统门店名称",
    type: "FormControl",
    pattern: /^\S*$/,
    message: "不能有空格",
    required: false,
    edit: false,
},
{
    // enname: "state",
    codename: "state",
    // showname: "state",
    zhname: "审批状态",
    type: "Select",
    hidepage: { 0: true },
    code: "BILL_STATUS",
    required: false,
    edit: false,
},
{
    enname:"ext01",
    zhname:"创建人",
    required: false,
    hidepage:{0:true,1:false,2:false},
    type: "FormControl",
    edit: false
},
{
    enname:"creationTime",
    zhname:"创建时间",
    required: false,
    hidepage:{0:true,1:false,2:false},
    type: "DatePicker",
    defaultValue:moment(),
    format:"YYYY-MM-DD",
    edit: false
},
{
    enname:"ext02",
    zhname:"最后修改人",
    required: false,
    hidepage:{0:true,1:false,2:false},
    type: "FormControl",
    edit: false
},
{
    enname:"modifiedTime",
    zhname:"修改时间",
    required: false,
    hidepage:{0:true,1:false,2:false},
    type: "DatePicker",
    defaultValue:moment(),
    format:"YYYY-MM-DD",
    edit: false
},
]

const FormDataHeaderOther = [
    {
        enname: "countersFate",
        zhname: "站柜人员数",
        type: "InputNumber",
        required: false,
        edit: false,
    },
    {
        enname: "cannumber",
        zhname: "可出样数",
        type: "InputNumber",
        required: true,
        edit: false,
    },
    {
        enname: "samplingFate",
        zhname: "出样数",
        type: "InputNumber",
        edit: false,
    },
    {
        enname: "provinceId",
        codename: "provinceCode",
        showname: "provinceName",
        zhname: "所属省",
        type: "RefComponent",
        refname: "areaRef",
        param: {
            EQ_areaLevel: "1",
        },
        cascadeName: {
            paramkey: "EQ_parent.id",
            childtype: "DataHeaderOther",
            refKey: "refpk",
            dtoKey: "provinceId",
            offers: "cityId",
            resetOffersFlag: true,
        },
        edit: false,
        required: true,
    },
    {
        enname: "cityId",
        codename: "cityCode",
        showname: "cityName",
        zhname: "所属地",
        refname: "areaRef",
        type: "RefComponent",
        edit: false,
        cascadeName: {
            paramkey: "EQ_parent.id",
            childtype: "DataHeaderOther",
            refKey: "refpk",
            dtoKey: "cityId",
            offers: "countyId",
            resetOffersFlag: true,
        },
        param: {
            EQ_areaLevel: "2",
        },
        alias: "provinceId",
        required: true,
    },
    {
        enname: "countyId",
        codename: "countyCode",
        showname: "countyName",
        zhname: "所属县/区",
        refname: "areaRef",
        type: "RefComponent",
        edit: false,
        param: {
            EQ_areaLevel: "3",
        },
        cascadeName: {
            paramkey: "EQ_parent.id",
            childtype: "DataHeaderOther",
            refKey: "refpk",
            dtoKey: "countyId",
            offers: "townId",
            resetOffersFlag: true,
        },
        alias: "cityId",
        edit: false,
        required: true,
    },
    {
        enname: "townId",
        codename: "townCode",
        showname: "townName",
        zhname: "所属镇/街道",
        refname: "areaRef",
        type: "RefComponent",
        param: {
            EQ_areaLevel: "4",
        },
        alias: "countyId",
        edit: false,
        required: false,
    },
    {
        enname: "address",
        zhname: "详细地址",
        type: "FormControl",
        required: false,
        pattern: /^\S*$/,
        message: "不能有空格",
        edit: false,
    },
    {
        enname: "longitude",
        zhname: "经度",
        type: "InputNumber",
        precision: 4,
        edit: false,
    },
    {
        enname: "latitude",
        zhname: "纬度",
        type: "InputNumber",
        precision: 4,
        edit: false,
    },
    {
        enname: "checkdr",
        zhname: "盘点标识",
        type: "Radio",
        options: [{
            "key": 1,
            "value": "是"
        }, {
            "key": 0,
            "value": "否"
        }],
        edit: false,
    },
    {
        enname: "isEnable",
        zhname: "是否停用",
        type: "Radio",
        options: [{
            key: 2,
            value: "停用"
        }, {
            key: 1,
            value: "启用"
        }],
        edit: false,
    },
    {
        enname: "openingDate",
        zhname: "开业日期",
        type: "DatePicker",
        hidepage:{0:false,1:false,2:false},
        required: true,
        edit: false,
    },
    {
        enname: "stopTime",
        zhname: "停用日期",
        type: "DatePicker",
        hidepage:{0:false,1:false,2:false},
        required: true,
        edit: false,
    },
    {
        enname: "stopCause",
        zhname: "停用原因",
        type: "FormControl",
        hidepage:{0:false,1:false,2:false},
        required: true,
        componentClass: "textarea",
        pattern: /^\S*$/,
        message: "不能有空格",
        edit: false,
    },
    {
        enname: "mail",
        zhname: "邮箱",
        type: "FormControl",
        required: false,
        pattern: /^\S*$/,
        message: "不能有空格",
        edit: false,
    },
    {
        enname: "mailSite",
        zhname: "邮寄地址",
        type: "FormControl",
        pattern: /^\S*$/,
        message: "不能有空格",
        required: false,
        edit: false,
    },
    {
        enname: "socioCreditCode",
        zhname: "社会信用代码",
        type: "FormControl",
        pattern: /^\S*$/,
        message: "不能有空格",
        edit: false,
    },
    {
        enname: "businessName",
        zhname: "工商注册名称",
        type: "FormControl",
        pattern: /^\S*$/,
        message: "不能有空格",
        edit: false,
    },
]


const columaterminalBases = [
    // {
    //     title: "终端类型",
    //     dataIndex: "seniorTerminalTypeName",
    //     key: "seniorTerminalTypeId",
    //     renderType: "refcomponent",
    //     filedProps: {
    //         title: "终端类型",
    //         refName: "terminalTypeRef",
    //         fieldName: "goodsCategoryName",
    //         reffields: { refpk: "seniorTerminalTypeId", refname: "seniorTerminalTypeName", refcode: "seniorTerminalTypeCode" }
    //     },
    // },
    {
        title: "门店等级",
        dataIndex: "terminalGradeName",
        key: "terminalGradeId",
        renderType: "refcomponent",
        required: true,
        filedProps: {
            title: "门店等级",
            refName: "terminalGradeRef",
            fieldName: "goodsCategoryName",
            reffields: { refpk: "terminalGradeId", refname: "terminalGradeName", refcode: "terminalGradeCode" }
        },
    },
    {
        title: "门店联系人",
        dataIndex: "contictsPersonName",
        key: "contictsPersonId",
        renderType: "input",
        required: true,
        filedProps: {
            maxLenght: 20,
        },
    },
    // {
    //     title: "门店联系人",
    //     dataIndex: "contictsPerson",
    //     key: "contictsPerson",
    //     renderType: "input",
    //     filedProps: {
    //         maxLenght: 20,
    //     },
    //     required: false,
    // },
    {
        title: "联系电话",
        dataIndex: "contictsPhone",
        key: "contictsPhone",
        renderType: "input",
        pattern: /^[0-9]{11}$/,
        patternMessage: "11位的数字",
        filedProps: {
            maxLenght: 20,
        },
        required: true,
    },
    // {
    //     title: "是否启用",
    //     dataIndex: "isEnable",
    //     key: "isEnable",
    //     // renderType: 'selectradio',
    //     hidepage: { 0: true },
    //     render: (text, record, index) => {
    //         return renderEnable(text);
    //     },
    //     filedProps: {
    //         reffields: { refpk: "isEnable" },
    //         defaultValue: 0,
    //         options: [
    //             {
    //                 name: '是', code: 1
    //             },
    //             {
    //                 name: '否', code: 0
    //             },
    //         ]
    //     }
    // },
    // {
    //     title: "停用日期",
    //     dataIndex: "enableTime",
    //     key: "enableTime",
    //     renderType: 'datepicker',
    //     render: (text, record, index) => {
    //         return text && ts2Formatter(text);
    //     },
    //     filedProps: {
    //         format: "YYYY-MM-DD",
    //     }
    // },
    // {
    //     title: "备注",
    //     dataIndex: "remark",
    //     key: "remark",
    //     renderType: "input",
    //     pattern: /^\S*$/,
    //     patternMessage: "不能有空格",
    //     edit: false,
    //     filedProps: {
    //         maxLenght: 20,
    //     },
    //     required: false,
    // },

]

const colummeterminalMarkets = [
    {
        title: "市场区域",
        dataIndex: "cityMarketName",
        key: "cityMarketId",
        renderType: "refcomponent",
        width: 250,
        disabled: true,
        validate: false,
        required: true,
        filedProps: {
            title: "市场区域",
            refName: "marketareas",
            fieldName: "cityMarketName",
            reffields: { refpk: "cityMarketId", refname: "cityMarketName", refcode: "cityMarketCode" }
        },
    },
]

const colummeterminalSuppliers = [
    {
        title: "客户",
        dataIndex: "customerName",
        key: "customerId",
        renderType: "refcomponent",
        width: 250,
        required: true,
        validate: false,
        filedProps: {
            title: "客户",
            refName: "terminalcustomerRef",
            aliasparam: [{
                paramkey: "EQ_customerAreas.organization.id",
                alias: "organizationId",
            }],
            constparam:{
                "EQ_isEnable":"1",
                "EQ_isFrozen": "0"
            },
            offersparam: {
                currentkey: ["businessId", "businessName", "businessCode", "custChanTypeId", "custChanTypeName", "custChanTypeCode", "shippingareaId", "shippingareaName", "shippingareaCode"],
                offerfields: ["blameserviceId", "blameserviceName", "blameserviceCode", "canalCategoryId", "canalCategoryName", "canalCategoryCode", "salesDeptId","salesDeptName","salesDeptCode"],
            },
            fieldName: "customerName",
            reffields: { refpk: "customerId", refname: "customerName", refcode: "customerCode" }
        },
    },

    // },
    // {
    //     title: "品项",
    //     dataIndex: "goodsCategoryName",
    //     key: "goodsCategoryId",
    //     renderType: "refcomponent",
    //     width: 250,
    //     required:true,
    //     validate:false,
    //     filedProps: {
    //         title: "品项",
    //         refName: "goodsCategoryRef",
    //         fieldName: "goodsCategoryName",
    //         reffields: { refpk: "goodsCategoryId", refname: "goodsCategoryName", refcode: "goodsCategoryCode" }
    //     },
    // },
    {
        title: "发运片区",
        dataIndex: "salesDeptName",
        key: "salesDeptId",
        renderType: "refcomponent",
        width: 100,
        required: true,
        filedProps: {
            title: "发运片区",
            refName: "departmentRef",
            aliasparam: [{
                paramkey: "EQ_organization.id",
                alias: "organizationId",
            }],
            constparam:{
                "EQ_enableState":"0",
                "EQ_isEnable":"1"
            },
            fieldName: "salesDeptName",
            reffields: { refpk: "salesDeptId", refname: "salesDeptName", refcode: "salesDeptCode" }
        },
    },
    {
        title: "渠道",
        dataIndex: "canalCategoryName",
        key: "canalCategoryId",
        // renderType: "refcomponent",
        width: 250,
        required: true,
        validate: false,
        filedProps: {
            title: "渠道",
            refName: "custchantype",
            fieldName: "canalCategoryName",
            reffields: { refpk: "canalCategoryId", refname: "canalCategoryName", refcode: "canalCategoryCode" }
        },
    },
    {
        title: "责任业务",
        dataIndex: "blameserviceName",
        key: "blameserviceId",
        renderType: "refcomponent",
        width: 250,
        required: true,
        validate: false,
        filedProps: {
            title: "责任业务",
            refName: "terminalPersonRef",
            aliasparam: [{
                paramkey: "EQ_personPosts.organization.id",
                alias: "organizationId",
            }],
            fieldName: "blameserviceName",
            reffields: { refpk: "blameserviceId", refname: "blameserviceName", refcode: "blameserviceCode" }
        },
    },
    {
        title: "商品品牌",
        dataIndex: "brandName",
        key: "brandId",
        renderType: "refcomponent",
        width: 200,
        validate: false,
        required: true,
        filedProps: {
            childType: "",
            title: "商品品牌",
            refName: "brandref",
            fieldName: "brandName",
            reffields: { refpk: "brandId", refname: "brandName", refcode: "brandCode" }
        },
    },
    {
        title: "商品品类",
        dataIndex: "categoryName",
        key: "categoryId",
        renderType: "refcomponent",
        width: 200,
        validate: false,
        required: true,
        filedProps: {
            childType: "",
            title: "商品品类",
            refName: "terminalGoodsCate",
            fieldName: "categoryName",
            reffields: { refpk: "categoryId", refname: "categoryName", refcode: "categoryCode" }
        },
    },
    {
        title: "是否默认",
        dataIndex: "sdefault",
        key: "sdefault",
        renderType: 'selectradio',
        required: true,
        validate: false,
        render: (text, record, index) => {
            if (text == 1) {
                return '是';
            } else {
                return '否';
            }
        },
        filedProps: {
            reffields: { refpk: "sdefault" },
            defaultValue: 0,
            options: [
                {
                    name: '是', code: 1
                },
                {
                    name: '否', code: 0
                },
            ]
        }
    },
]

const columnterminalPersons = [
    {
        title: "人员",
        dataIndex: "personName",
        key: "personId",
        renderType: "refcomponent",
        width: 250,
        required: true,
        filedProps: {
            title: "人员",
            refName: "terminalPersonRef",
            fieldName: "personName",
            offersparam: {
                currentkey: ["phone"],
                offerfields: ["personPhone"],
            },
            reffields: { refpk: "personId", refname: "personName", refcode: "personCode" }
        },
    },
    {
        title: "电话",
        dataIndex: "personPhone",
        key: "personPhone",
        renderType: "input",
        required: true,
        pattern: /^[0-9]{11}$/,
        patternMessage: "11位的数字",
        filedProps: {
            maxLenght: "20",
        },
    },
]
//表单字段

export const FormField = {
    "DataHeader": {
        "title": "基础信息",
        "Field": FormDataHeader
    },
    "DataHeaderOther": {
        "title": "辅助信息",
        "Field": FormDataHeaderOther
    },
}

//表格弹框表单字段
export const FormTableField = {
}

//渲染成字表表格的头
export const childTableColumn = {
    "terminalBases": {
        "title": "联系信息",
        "type": "grid",
        "column": columaterminalBases
    },
    // "terminalMarkets": {
    //     "title": "市场区域",
    //     "type": "grid",
    //     "column": colummeterminalMarkets
    // },
    "terminalSuppliers": {
        "title": "客户信息",
        "type": "grid",
        "column": colummeterminalSuppliers
    },
    "terminalPersons": {
        "title": "负责人员",
        "type": "grid",
        "column": columnterminalPersons
    },
}

//渲染成字表表格的头
export const mainTableColumn = [
    {
        title: "变更单号",
        dataIndex: "code",
        width: 110,
        key: "code",
        render: (text, record) => {
            return <a style={{ "cursor": "pointer" }}
                onClick={() => {
                    actions.routing.push(
                        {
                            pathname: 'TerminalChange-edit',
                            search: `?search_id=${record.id}&btnPageFlag=2`,
                        }
                    );
                    // location.reload();
                }}
            >
                {text}
            </a >;
        }
    },
    {
        title:"RIS门店编码",
        dataIndex:"riscode",
        width: 110,
        key:"riscode",
    },
    {
        title: "终端编码",
        dataIndex: "srcBillCode",
        width: 150,
        key: "srcBillCode",
    },
    {
        title: "终端名称",
        dataIndex: "name",
        width: 150,
        key: "name",
    },
    {
        title: "变更原因",
        dataIndex: "changeReasonName",
        key: "changeReasonName",
        width: 100,
    },
    {
        title: "审批状态",
        dataIndex: "state",
        key: "state",
        width: 100,
        render:(text, record, index)=> {
            return renderState(text);
        }
    },
    {
        title: "终端渠道类型名称",
        dataIndex: "canalTypeName",
        width: 150,
        key: "canalTypeName",
    },
    {
        title: "门店渠道",
        dataIndex: "canalCategoryName",
        width: 125,
        key: "canalCategoryName",
    },
    {
        title: "门店类别",
        dataIndex: "facadeCategoryName",
        width: 100,
        key: "facadeCategoryName",
    },
    {
        title: "人员属性",
        dataIndex: "peopleAttributeName",
        width: 100,
        key: "peopleAttributeName",
    },
    {
        title: "零售片区",
        dataIndex: "retailName",
        width: 110,
        key: "retailName",
    },
    // {
    //     title: "发运片区",
    //     dataIndex: "shippingareaName",
    //     width: 110,
    //     key: "shippingareaName",
    // },
    {
        title:"市场层面",
        dataIndex: "marketLevelName",
        width: 90,
        key: "marketLevelName",
    },
    {
        title:"创建人",
        dataIndex: "ext01",
        width: 90,
        key: "ext01",
    },
    {
        title: "创建时间",
        dataIndex: "creationTime",
        key: "creationTime",
        width: 150,
        render: (text, record, index) => {
            return text && ts2Formatter(text);
        }
    }

]

export const searchField = [
    {
        enname: "organizationId",
        showname: "organizationName",
        codename: "organizationCode",
        zhname: "隶属组织",
        param:{
            "AUTH_refdim":"organization","AUTH_refcod":"terminal"
        },
        multiple: true,
        type: "RefComponent",
        refname: "organization",
        edit: true,
        cascadeName: [{
            paramkey: "EQ_organization.id",
            childtype: "DataHeader",
            refKey: "refpk",
            dtoKey: "organizationId",
            offers: "retailId",
            resetOffersFlag: true,
            }
        ]
    },
    {
        enname: "code",
        zhname: "变更单号",
        searchType: "like",
        type: "FormControl",
        edit: true,
    },
    {
        enname: "changeReasonId",
        codename: "changeReasonCode",
        showname: "changeReasonName",
        zhname: "变更原因",
        multiple: true,
        refname:"changeReasonRef",
        type: "RefComponent",
        edit: true
    },
    {
        enname: "name",
        zhname: "门店名称",
        type: "FormControl",
        searchType: "like",
        pattern: /^\S*$/,
        patternMessage: "不能有空格",
        edit: true,
        required: false,
    },
    {
        enname: "facadeShort",
        zhname: "门店简称",
        type: "FormControl",
        searchType: "like",
        pattern: /^\S*$/,
        patternMessage: "不能有空格",
        edit: true,
        required: false,
    },
    {
        enname: "riscode",
        zhname: "RIS门店编码",
        searchType: "like",
        type: "FormControl",
        edit: true,
    },
    {
        enname: "canalCategoryId",
        codename: "canalCategoryCode",
        showname: "canalCategoryName",
        zhname: "渠道",
        multiple: true,
        param:{
            "EQ_enableState":"2"
        },
        refname: "custchantype",
        type: "RefComponent",
        edit: true,
    },
    {
        enname: "facadeCategoryId",
        codename: "facadeCategoryCode",
        showname: "facadeCategoryName",
        zhname: "门店类别",
        multiple: true,
        refname: "facadeCategoryRef",
        type: "RefComponent",
        edit: true
    },
    {
        enname: "peopleAttributeId",
        codename: "peopleAttributeCode",
        showname: "peopleAttributeName",
        zhname: "人员属性",
        multiple: true,
        refname: "persontypes",
        type: "RefComponent",
        edit: true,
    },
    {
        enname: "retailId",
        codename: "retailCode",
        showname: "rretailName",
        // zhname: "片区",
        zhname: "零售片区",
        multiple: true,
        alias: "organizationId",
        refname: "departmentRef",
        type: "RefComponent",
        edit: true,
    },
    // {
    //     enname: "shippingareaId",
    //     codename: "shippingareaCode",
    //     showname: "shippingareaName",
    //     // zhname: "片区",
    //     zhname: "发运片区",
    //     refname: "departmentRef",
    //     type: "RefComponent",
    //     edit: true,
    // },
    {
        enname: "regionId",
        codename: "regionCode",
        showname: "regionName",
        zhname: "区域市场",
        multiple: true,
        refname: "marketareas",
        type: "RefComponent",
        edit: true,
    },
    {
        enname: "terminalSuppliers&customerId",
        codename: "terminalSuppliers&customerCode",
        showname: "terminalSuppliers&customerName",
        zhname: "隶属客户",
        multiple: true,
        refname: "terminalcustomerRef",
        type: "RefComponent",
        edit: true,
    },
    {
        enname: "blameserviceId",
        codename: "blameserviceCode",
        showname: "blameserviceName",
        zhname: "责任业务",
        multiple: true,
        refname: "terminalPersonRef",
        type: "RefComponent",
        edit: true,
    },
        {
        enname: "terminalBases&terminalGradeId",
        codename: "terminalBases&terminalGradeCode",
        showname: "terminalBases&terminalGradeName",
        zhname: "门店等级",
        multiple: true,
        refname: "terminalGradeRef",
        type: "RefComponent",
        edit: true,
    },
    {
        enname: "terminalSuppliers&brandId",
        codename: "terminalSuppliers&brandCode",
        showname: "terminalSuppliers&brandName",
        zhname: "品牌",
        multiple: true,
        refname: "brandref",
        type: "RefComponent",
        edit: true,
    },
    {
        enname: "terminalSuppliers&categoryId",
        codename: "terminalSuppliers&categoryCode",
        showname: "terminalSuppliers&categoryName",
        zhname: "品类",
        multiple: true,
        refname: "terminalGoodsCate",
        type: "RefComponent",
        edit: true,
    },
    {
        enname: "stradeAreaId",
        codename: "stradeAreaCode",
        showname: "stradeAreaName",
        zhname: "隶属商圈",
        multiple: true,
        refname:"stradeAreaRef",
        type: "RefComponent",
        edit: true
    },
    {
        enname: "canalTypeId",
        codename: "canalTypeCode",
        showname: "canalTypeName",
        zhname: "终端渠道类型",
        multiple: true,
        refname: "terminalCustRef",
        type: "RefComponent",
        edit: true,
    },
    {
        enname:"state",
        zhname:"审批状态",
        required: false,
        code:"BILL_STATUS",
        type: "Select",
        edit: true
    },
    {
        enname: "creator",
        zhname: "创建人编码",
        type: "FormControl",
        searchType: "like",
        edit: true,
    },
    {
        enname: "creationTime",
        zhname: "创建时间",
        type: "RangePicker",
        rangeField:["creationTime","creationTime"],
        edit:true,
    },
    // {
    //     enname: "code",
    //     zhname: "门店编码",
    //     searchType: "like",
    //     type: "FormControl",
    //     edit: true,
    // },
    // {
    //     enname: "name",
    //     zhname: "门店名称",
    //     type: "FormControl",
    //     searchType: "like",
    //     pattern: /^\S*$/,
    //     patternMessage: "不能有空格",
    //     edit: true,
    //     required: false,
    // },
    // {
    //     enname: "provinceId",
    //     codename: "provinceCode",
    //     showname: "provinceName",
    //     zhname: "省份",
    //     type: "RefComponent",
    //     refname: "areaRef",
    //     param: {
    //         EQ_areaLevel: "1",
    //     },
    //     cascadeName: {
    //         paramkey: "EQ_parent.id",
    //         childtype: "DataHeader",
    //         refKey: "refpk",
    //         dtoKey: "provinceId",
    //         offers: "cityId",
    //         resetOffersFlag: true,
    //     },
    //     edit: true,
    //     // required: true,
    // },
    // {
    //     enname: "cityId",
    //     codename: "cityCode",
    //     showname: "cityName",
    //     zhname: "市",
    //     refname: "areaRef",
    //     type: "RefComponent",
    //     edit: true,
    //     cascadeName: {
    //         paramkey: "EQ_parent.id",
    //         childtype: "DataHeader",
    //         refKey: "refpk",
    //         dtoKey: "cityId",
    //         offers: "countyId",
    //         resetOffersFlag: true,
    //     },
    //     param: {
    //         EQ_areaLevel: "2",
    //     },
    //     alias: "provinceId",
    // },
    // {
    //     enname: "organizationId",
    //     showname: "organizationName",
    //     codename: "organizationCode",
    //     zhname: "隶属组织",
    //     multiple: true,
    //     type: "RefComponent",
    //     param:{
    //         "AUTH_refdim":"organization","AUTH_refcod":"TerminalChange"
    //     },
    //     refname: "organization",
    //     edit: true,
    // },
    // {
    //     enname: "canalTypeId",
    //     codename: "canalTypeCode",
    //     showname: "canalTypeName",
    //     zhname: "门店渠道类型",
    //     refname: "terminalCustRef",
    //     type: "RefComponent",
    //     edit: true,
    // }, {
    //     enname: "regionId",
    //     codename: "regionCode",
    //     showname: "regionName",
    //     zhname: "区域市场",
    //     refname: "marketareas",
    //     type: "RefComponent",
    //     edit: true,
    // },
]

export const headerButtonSets = [
]

export const columnButtonSets = {
    "delete": {
        event: "ButtonDel",
        zhname: "删除",
        batch: true,
        method: "post",
        ContentType: 'application/x-www-form-urlencoded;charset=utf-8',
        url: 'occ-base/base/terminal-store-modify/deleteout'
    },
    "edit": true,
    "detail": true
}

// export default {mainTableColumn,searchField,headerButtonSets,
//     columnButtonSets,childTableColumn,FormTableField,FormField}
export const SelectCode = ["SQ001", "SCM", "MD002", "YJ001","BILL_STATUS", "BGYY"]
